import 'package:enterprise_v6_app/app/components/common/custom_no_data.dart';
import 'package:enterprise_v6_app/app/components/common/custom_text_widget.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_intrinsic_circle_line.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/data/entities/application/emergency/emergency_record_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/emergency_plan/emergency_plan_details/memo_record/memo_record_controller.dart';

/// 备案记录页面
class MemoRecordPage extends StatelessWidget {
  MemoRecordPage({super.key});

  final controller = Get.put(MemoRecordController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Container(
            alignment: Alignment.topCenter,
            color: const Color(0xffffffff),
            child: controller.dataList.isEmpty
                ? const CustomNoData()
                : ListView.builder(
                    padding: EdgeInsets.symmetric(horizontal: 27.w, vertical: 22.w),
                    itemCount: controller.dataList.length,
                    shrinkWrap: true,
                    physics: const BouncingScrollPhysics(),
                    itemBuilder: (context, index) {
                      return CustomIntrinsicCircleLine(
                        showWidget: _getTrainView(controller.dataList[index], index),
                      );
                    }),
          );
        });
  }

  ///获取流程显示
  Widget _getTrainView(EmergencyRecordEntity item, int index) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Text(
              '第${index + 1}次备案',
              style: TextStyle(
                fontSize: 15.sp,
                fontWeight: FontWeight.w400,
                color: const Color(0xff262F38),
              ),
            ),
            AppGaps.hGap12,
            Text(
              item.filingsDate,
              style: TextStyle(
                fontSize: 12.sp,
                fontWeight: FontWeight.w400,
                color: const Color(0xff495061),
              ),
            ),
          ],
        ),
        AppGaps.vGap12,
        Container(
          padding: EdgeInsets.all(12.w),
          alignment: Alignment.topLeft,
          decoration: BoxDecoration(
            color: const Color(0xffF7F7FB),
            border: Border.all(
              color: const Color(0xffEBEDF0),
              width: 1.w,
            ),
            borderRadius: BorderRadius.circular(4.r),
          ),
          constraints: BoxConstraints(minHeight: 80.w),
          child: SingleChildScrollView(
            child: Column(
              children: [
                CustomTextWidget.getTextRowView(title: '备案日期：', value: item.filingsDate),
                AppGaps.vGap14,
                CustomTextWidget.getTextRowView(title: '备案部门：', value: item.filingsDepartment),
                AppGaps.vGap14,
                CustomTextWidget.getTextRowView(title: '备案部门性质：', value: item.filingsDepartmentNatureName),
                AppGaps.vGap14,
                CustomTextWidget.getTextRowView(title: '有效期限：', value: item.validPeriodName),
                AppGaps.vGap14,
                CustomTextWidget.getFileRowView(title: '预案备案登记资料：', fileList: [item.planFilingFileUrl]),
                AppGaps.vGap14,
                CustomTextWidget.getFileRowView(title: '预案备案申请表：', fileList: [item.planFilingApplyForUrl]),
              ],
            ),
          ),
        ),
        AppGaps.vGap16,
      ],
    );
  }
}
